package huang.homework12;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Dao {
		public boolean update(String sql){
			boolean result =false;
			BaseDao bd=new BaseDao();
			Connection con=bd.getCon();
			try {
				PreparedStatement ps=con.prepareStatement(sql);
				ps.executeUpdate();
				if(ps!=null){
					ps.close();
				}
				if(con!=null){
					con.close();
				}
				result=true;
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
				return result;
		}
		
		public boolean delete(String sql){
			boolean result =false;
			BaseDao bd=new BaseDao();
			Connection con=bd.getCon();
			try {
				PreparedStatement ps=con.prepareStatement(sql);
				
				ps.executeUpdate();
				if(ps!=null){
					ps.close();
				}
				if(con!=null){
					con.close();
				}
				result=true;
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
				return result;
		}
}
